(function(e,i,s){"use strict";var t,a;function l(e,i){o(e,i);i.add(e)}function r(e,i,s){if(!i.has(e)){throw new TypeError("attempted to get private field on non-instance")}return s}function n(e,i,s){o(e,i);i.set(e,s)}function o(e,i){if(i.has(e)){throw new TypeError("Cannot initialize the same private elements twice on an object")}}var c=i.Reflection.namespace("BX.Ui.Form");var d=new WeakMap;var b=function e(i){var s=this;babelHelpers.classCallCheck(this,e);babelHelpers.defineProperty(this,"isOpen",false);n(this,d,{writable:true,value:[]});babelHelpers.defineProperty(this,"popupContainer",null);i.scopes.forEach((function(e){e.config=s;babelHelpers.classPrivateFieldGet(s,d).push(new BX.Ui.Form.ConfigItem(e))}),this);this.popupContainer=i.componentId};var p=new WeakMap;var h=new WeakMap;var u=new WeakMap;var v=new WeakMap;var m=new WeakMap;var f=new WeakMap;var H=new WeakMap;var C=new WeakSet;var I=new WeakSet;var F=new WeakSet;var g=new WeakSet;var T=new WeakSet;var P=new WeakSet;var w=new WeakSet;var E=new WeakSet;var k=function(e){babelHelpers.inherits(i,e);function i(e){var s;babelHelpers.classCallCheck(this,i);s=babelHelpers.possibleConstructorReturn(this,babelHelpers.getPrototypeOf(i).call(this));l(babelHelpers.assertThisInitialized(s),E);l(babelHelpers.assertThisInitialized(s),w);l(babelHelpers.assertThisInitialized(s),P);l(babelHelpers.assertThisInitialized(s),T);l(babelHelpers.assertThisInitialized(s),g);l(babelHelpers.assertThisInitialized(s),F);l(babelHelpers.assertThisInitialized(s),I);l(babelHelpers.assertThisInitialized(s),C);n(babelHelpers.assertThisInitialized(s),p,{writable:true,value:void 0});n(babelHelpers.assertThisInitialized(s),h,{writable:true,value:void 0});n(babelHelpers.assertThisInitialized(s),u,{writable:true,value:void 0});n(babelHelpers.assertThisInitialized(s),v,{writable:true,value:void 0});n(babelHelpers.assertThisInitialized(s),m,{writable:true,value:void 0});n(babelHelpers.assertThisInitialized(s),f,{writable:true,value:"BX.Ui.Form.ConfigItem:onComponentOpen"});n(babelHelpers.assertThisInitialized(s),H,{writable:true,value:"BX.Main.SelectorV2:reInitDialog"});s.setEventNamespace("BX.Ui.Form");babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(s),p,e["scopeId"]||null);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(s),h,e["members"]||null);babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(s),u,BX("ui-editor-config-".concat(babelHelpers.classPrivateFieldGet(babelHelpers.assertThisInitialized(s),p))));babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(s),v,null);s.drawingIconsLimit=e["drawingIconsLimit"]||10;babelHelpers.classPrivateFieldSet(babelHelpers.assertThisInitialized(s),m,e["moduleId"]||null);s.config=e["config"]||null;r(babelHelpers.assertThisInitialized(s),C,z).call(babelHelpers.assertThisInitialized(s));s.addToAccessCodesHandler=BX.delegate(s.onAddToAccessCodes,babelHelpers.assertThisInitialized(s));s.removeFromAccessCodesHandler=BX.delegate(s.onRemoveFromAccessCodes,babelHelpers.assertThisInitialized(s));s.closePopupHandler=BX.delegate(s.onClosePopup,babelHelpers.assertThisInitialized(s));BX.addCustomEvent("Grid::updated",s.onGridUpdate.bind(babelHelpers.assertThisInitialized(s)));setTimeout((function(){BX.onCustomEvent("BX.Ui.Form.ConfigItem:onComponentLoad",[{openDialogWhenInit:false}])}),100);return s}babelHelpers.createClass(i,[{key:"onGridUpdate",value:function e(i){r(this,E,W).call(this)}},{key:"onClosePopup",value:function e(i){this.config.isOpen=false;r(this,w,U).call(this)}},{key:"onAddToAccessCodes",value:function e(i){var s=this;BX.ajax.runComponentAction("bitrix:ui.form.config","updateScopeAccessCodes",{data:{moduleId:babelHelpers.classPrivateFieldGet(this,m),scopeId:babelHelpers.classPrivateFieldGet(this,p),accessCodes:r(this,P,S).call(this)}}).then((function(e){r(s,E,W).call(s,e.data)}))}},{key:"onRemoveFromAccessCodes",value:function e(i){this.onAddToAccessCodes(i)}}],[{key:"onMemberSelect",value:function e(i){if(i.state==="select"){s.EventEmitter.emit("BX.Ui.Form.ConfigItem:addToAccessCodes",i)}}},{key:"onDialogClose",value:function e(i){s.EventEmitter.emit("BX.Ui.Form.ConfigItem:closePopup",i)}},{key:"onMemberUnselect",value:function e(i){s.EventEmitter.emit("BX.Ui.Form.ConfigItem:removeFromAccessCodes",i)}}]);return i}(s.EventEmitter);function z(){if(babelHelpers.classPrivateFieldGet(this,h)){var e=0;for(var i in babelHelpers.classPrivateFieldGet(this,h)){var s=babelHelpers.classPrivateFieldGet(this,h)[i];babelHelpers.classPrivateFieldGet(this,u).appendChild(r(this,I,B).call(this,s));if(e++>this.drawingIconsLimit){break}}}babelHelpers.classPrivateFieldGet(this,u).appendChild(r(this,F,X).call(this))}function B(e){var s=e.avatar?i.Tag.render(t||(t=babelHelpers.taggedTemplateLiteral(['<a href="','" class="ui-editor-config-item-avatar"  title="','" style="background-image: url(\'',"')\"></a>"])),e.url,i.Text.encode(e.name),e.avatar):i.Tag.render(a||(a=babelHelpers.taggedTemplateLiteral(['<a href="','" class="ui-icon ui-icon-xs ui-icon-common-user" title="','"><i></i></a>'])),e.url,i.Text.encode(e.name));return i.Dom.create("div",{attrs:{class:"ui-editor-config-item"},children:[s]})}function X(){var e=this;return i.Dom.create("div",{events:{click:function i(s){if(!e.config.isOpen){r(e,g,G).call(e)}}},attrs:{class:"ui-editor-config-item ui-editor-config-item--add"}})}function G(){this.config.isOpen=true;r(this,T,A).call(this);var e=BX.Main.selectorManagerV2.controls[this.config.popupContainer].selectorInstance;e.itemsSelected={};BX.onCustomEvent(babelHelpers.classPrivateFieldGet(this,f),[{id:this.config.popupContainer,bindNode:babelHelpers.classPrivateFieldGet(this,u)}]);BX.onCustomEvent(babelHelpers.classPrivateFieldGet(this,H),[{selectorId:this.config.popupContainer,selectedItems:r(this,P,S).call(this)}])}function A(){s.EventEmitter.subscribe("BX.Ui.Form.ConfigItem:addToAccessCodes",this.addToAccessCodesHandler);s.EventEmitter.subscribe("BX.Ui.Form.ConfigItem:removeFromAccessCodes",this.removeFromAccessCodesHandler);s.EventEmitter.subscribe("BX.Ui.Form.ConfigItem:closePopup",this.closePopupHandler)}function S(){if(babelHelpers.classPrivateFieldGet(this,h)&&!babelHelpers.classPrivateFieldGet(this,v)){var e={};for(var i in babelHelpers.classPrivateFieldGet(this,h)){e[i]=babelHelpers.classPrivateFieldGet(this,h)[i].type.toUpperCase()}babelHelpers.classPrivateFieldSet(this,v,e)}return babelHelpers.classPrivateFieldGet(this,v)||{}}function U(){s.EventEmitter.unsubscribe("BX.Ui.Form.ConfigItem:addToAccessCodes",this.addToAccessCodesHandler);s.EventEmitter.unsubscribe("BX.Ui.Form.ConfigItem:removeFromAccessCodes",this.removeFromAccessCodesHandler);s.EventEmitter.unsubscribe("BX.Ui.Form.ConfigItem:closePopup",this.closePopupHandler)}function W(e){babelHelpers.classPrivateFieldSet(this,u,BX("ui-editor-config-".concat(babelHelpers.classPrivateFieldGet(this,p))));if(e){babelHelpers.classPrivateFieldSet(this,h,e)}if(babelHelpers.classPrivateFieldGet(this,u)){while(babelHelpers.classPrivateFieldGet(this,u).firstChild){babelHelpers.classPrivateFieldGet(this,u).removeChild(babelHelpers.classPrivateFieldGet(this,u).firstChild)}r(this,C,z).call(this)}}c.Config=b;c.ConfigItem=k})(this.window=this.window||{},BX,BX.Event);
//# sourceMappingURL=script.map.js